package com.feihao.zhou.controller;


import com.feihao.zhou.domain.User.User;
import com.feihao.zhou.exception.BusinessException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller

public class UserController {
    //异步接收请求参数练习：
    @ResponseBody
    @RequestMapping("/test01")
    public String test01(@RequestBody String name){
        System.out.println(name);
        return "success!";
    }

    @ResponseBody
    @RequestMapping("/ajaxPojoToController")
    public String test02(@RequestBody User user){
        System.out.println(user);
        return "success";
    }

    @ResponseBody
    @RequestMapping("/ajaxReturnString")
    public String test03(){
        System.out.println("接收到了！");
        return "hahahaha";
    }


    @ResponseBody
    @RequestMapping("/ajaxReturnJson")
    @CrossOrigin     //跨域访问
    public User test04(){
        User user = new User("ss",55);
        System.out.println("返回了");
        return user;
    }


}
